home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / PROPSHEE.H < prev    next >
C/C++ Source or Header  |  1980-01-03  |  4KB  |  119 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Property sheet of user-customizable variables.
  25.  */
  26.  
  27. #ifndef propsheet_h
  28. #define propsheet_h
  29.  
  30. #include <InterViews/defs.h>
  31.  
  32. typedef class StringId* PropertyName;
  33. typedef const char* PropertyType;
  34. typedef const char* PropertyValue;
  35.  
  36. class PropDir;
  37. class PropPath;
  38.  
  39. /*
  40.  * A property is defined by a name, optional type, and value.
  41.  */
  42.  
  43. class PropertyDef {
  44. public:
  45.     PropertyName name;
  46.     PropertyType type;
  47.     PropertyValue value;
  48.  
  49.     PropertyDef () {}
  50.     PropertyDef (PropertyName n) { name = n; value = nil; }
  51. };
  52.  
  53. class PropertySheet {
  54. public:
  55.     PropertySheet();
  56.     ~PropertySheet();
  57.  
  58.     /* individual property operations */
  59.     boolean Get(PropertyDef&);
  60.     boolean GetLocal(PropDir*, PropertyDef&);
  61.     PropDir* MakeDir(const char* path);
  62.     void Put(const char* path, const char* value, const char* type = nil);
  63.     void PutLower(const char* path, const char* value, const char* type = nil);
  64.     void PutLocal(
  65.     PropDir*, const char* path, const char* value, const char* type = nil
  66.     );
  67.     void PutLocalLower(
  68.     PropDir*, const char* path, const char* value, const char* type = nil
  69.     );
  70.  
  71.     /* property tree navigation */
  72.     PropDir* Find(PropertyName name);
  73.     void Pop();
  74.     void Push(PropDir*, boolean sibling);
  75.     PropDir* Root();
  76.  
  77.     /* external interface */
  78.     void LoadProperty(const char*);
  79.     void LoadList(const char*);
  80.     boolean LoadFile(const char* filename);
  81. private:
  82.     PropDir* cur;
  83.     PropPath* head;
  84.     PropPath* tail;
  85.  
  86.     void DoPut(
  87.     PropDir* dir, const char* path, const char* value, const char* type,
  88.     boolean override
  89.     );
  90. };
  91.  
  92. extern PropertySheet* properties;
  93.  
  94. inline void PropertySheet::Put (
  95.     const char* path, const char* value, const char* type
  96. ) {
  97.     DoPut(cur, path, value, type, true);
  98. }
  99.  
  100. inline void PropertySheet::PutLower (
  101.     const char* path, const char* value, const char* type
  102. ) {
  103.     DoPut(cur, path, value, type, false);
  104. }
  105.  
  106. inline void PropertySheet::PutLocal (
  107.     PropDir* dir, const char* path, const char* value, const char* type
  108. ) {
  109.     DoPut(dir, path, value, type, true);
  110. }
  111.  
  112. inline void PropertySheet::PutLocalLower (
  113.     PropDir* dir, const char* path, const char* value, const char* type
  114. ) {
  115.     DoPut(dir, path, value, type, false);
  116. }
  117.  
  118. #endif
  119.